// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'

import 'babel-polyfill'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import App from './App'
import router from './router'
import $ from 'jquery'

import '../node_modules/bootstrap/dist/css/bootstrap.min.css';
import '../node_modules/bootstrap/dist/js/bootstrap.min.js';


import axios from 'axios'
import store from './vuex/store'
import Vuex from 'vuex';

//注册ElementUI
Vue.use(ElementUI);
Vue.use(Vuex);
Vue.config.productionTip = false;
Vue.prototype.$axios = axios;
/* eslint-disable no-new */

router.beforeEach((to, from, next) => {

  if (store.state.userInfo.userAccount) {
    if (to.path == '/login') {
     
      if (confirm("确定要退出吗？")) {
        next();
      } else {
        next(false);
      }
    } else {
      next();
    }

  } else {
    if (to.path == '/login' || to.path == '/register') {

      next();

    } else {
      alert("还没有登录，请先登录");
      next('/login');
    }
  }
});
new Vue({
  el: '#app',
  router,
  store: store,
  components: {
    App
  },
  template: '<App/>'
})
